package com.mdd.common.mapper.course;

import com.mdd.common.core.basics.IBaseMapper;
import com.mdd.common.entity.course.Course;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 课程Mapper
 */
@Mapper
public interface CourseMapper extends IBaseMapper<Course> {

    @Select("SELECT COUNT(ID) FROM ls_course WHERE category_id = #{categoryId} AND delete_time IS NULL")
    Long countByCategory(Integer categoryId);

    @Select({"SELECT course.* FROM ls_coupon_course cc INNER JOIN ls_course course ON cc.course_id = course.id WHERE cc.coupon_id = #{couponId}"})
    List<Course> getCourseByCouponId(Integer couponId);

    @Select({"SELECT course.id FROM ls_coupon_course cc INNER JOIN ls_course course ON cc.course_id = course.id WHERE cc.coupon_id = #{couponId}"})
    List<Integer> getCourseIdByCouponId(Integer couponId);

}
